#include "GeomEffect.h"

GeomEffect::GeomEffect() : m_device(0), m_effect(0), m_colorHandle(0), m_worldViewProjHandle(0)
{
}

GeomEffect::GeomEffect( D3DDevice device )
{
	initialize( device );
}

GeomEffect::~GeomEffect(void)
{
	destroy();
}

void GeomEffect::initialize( D3DDevice device )
{
	m_device = device;
	D3DXCreateEffectFromFile( m_device, TEXT(".\\shaders\\Geom.fx"), 0, 0, 0, 0, &m_effect, 0 );
	m_colorHandle = m_effect->GetParameterBySemantic( NULL, "COLOR" );
	m_worldViewProjHandle = m_effect->GetParameterBySemantic( NULL, "WORLDVIEWPROJ" );
}

void GeomEffect::destroy()
{
	SAFE_RELEASE( m_effect );
}

void GeomEffect::setColor(float4 const & col)
{
	m_effect->SetVector( m_colorHandle, &col );
}

void GeomEffect::setWorldViewProj(float44 const & mat)
{
	m_effect->SetMatrix( m_worldViewProjHandle, &mat );
}

Effect GeomEffect::effect()
{
	return m_effect;
}
